# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

from appium import webdriver
import time

caps = {}
caps["platformName"] = "Android"
caps["platformVersion"] = "4.4"
caps["deviceName"] = "127.0.0.1:62001"
caps["browserName"] = ''
caps["app"] = "D:\\Apps\\com.tencent.mm.apk"
caps["appPackage"] = "com.tencent.mm"
caps["appActivity"] = ".ui.LauncherUI"
caps["fastReset"] = "false"
caps["fullReset"] = "false"
caps["noReset"] = "true"

driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)

driver.implicitly_wait(100)
  # val options = new ChromeOptions()
  # options.setExperimentalOption("androidProcess", "com.tencent.mm:appbrand1")
  # capability.setCapability(ChromeOptions.CAPABILITY, options)

driver.find_element_by_xpath("//*[@text='发现']").click()
driver.find_element_by_xpath("//*[@text='小程序']").click()
driver.find_element_by_xpath("//*[contains(@text, '摩拜单车')]").click()

driver.context("WEBVIEW_com.tencent.mm:tools")
time.sleep(5000)

driver.find_element_by_xpath("//*[contains(@text, '扫码开锁')]").click()


